// Created 4/17/09
// Author: Dustin McBeth

// Purpose: Hex to Int
// #include <cstdlib.h>

char toUpper(char myChar) {
	if(myChar>91) myChar-=32;
	return myChar;

}

int htoi(char myArray[4]) {
	int tempInt=0;
	int tempArray[4];
	
	// we are setting hex value to lone ints
	for(int i=0; i<4; i++) {
	  // if lower case, then change to upper case to deal with
	  if(myArray[i]>'9') {
	    myArray[i] = toUpper(myArray[i]);
	    // if it's a letter make it a whole number
	    tempArray[i] = (myArray[i]-55);
	    // if it's a character number, make a value of that number
	  } else {
	    // else we got a char of a number, make it a real number
	    tempArray[i] -=48;
	  }
	}
	
	// we multiply ints together to get final int
	tempInt = tempArray[3];
	tempInt += (tempArray[2]*16);
	tempInt += (tempArray[1]*16*16);
	tempInt += (tempArray[0]*16*16*16);
	
	return tempInt;
}

